﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection ;



namespace reflect
{
    class test
    {
        public string joke()
        {
            return "No joke";
        }
        public string hw()
        {
            return "Hello, World!";
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            test t = new test();
            string method_to_call;
            while (true)
            {
                Console.WriteLine("Enter method to invoke.");
                method_to_call = Console.ReadLine();
                if (string.Compare(method_to_call, "exit") == 0)
                {
                    break;
                }
                else
                {
                    if ((string.Compare(method_to_call, "hw") == 0) || (string.Compare(method_to_call, "joke") == 0))
                    {
                        string a = (string)t.GetType().InvokeMember(method_to_call, BindingFlags.InvokeMethod, null, t, null);
                        Console.WriteLine(a);
                    }
                    else
                    {
                        Console.WriteLine("Unknown method!");
                    }
                }
            }
        }
    }
}
